package com.ehualu.esresult.utils;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class GetDBConnection {

    private static final Logger LOG = LoggerFactory.getLogger(GetDBConnection.class);


    public Connection getdbconn() {

        LoadProperties loadProc = LoadProperties.getInstance();

        Connection con = null;
        String driver = loadProc.getValues("dbdriver", "com.mysql.jdbc.Driver");
        String dburl = loadProc.getValues("dburl", "jdbc:mysql://192.168.22.18:3306/esresult");
        String dbusername = loadProc.getValues("dbusername", "root");
        String dbpassword = loadProc.getValues("dbpassword", "root");
        try {


            Class.forName(driver);
            con = DriverManager.getConnection(dburl, dbusername, dbpassword);

            LOG.info("ehl db Connection create!");

        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return con;
    }


}
